T
Chili.Opf3 Send comments on this topic.
Generic GetObjectSet(PersistentTypeSelector,String,Object[]) Method
See Also  Example
Chili.Opf3 Namespace > ObjectContext Class > GetObjectSet Method : Generic GetObjectSet(PersistentTypeSelector,String,Object[]) Method




typeSelector
Delegate invoked before each creating of a persistent object. This allows to dynamically change the type of the created persistent object or ignore some objects.
conditions
A condition string that specifies the objects that are loaded.
parameter
A list of parameter that is passed as parameter for the conditions.
Fills an ObjectSet with objects.

Syntax

Visual Basic (Declaration) 
Overloads Public Overridable Function GetObjectSet(Of T)( _
   ByVal typeSelector As PersistentTypeSelector, _
   ByVal conditions As String, _
   ByVal ParamArray parameter() As Object _
) As ObjectSet(Of T)
Visual Basic (Usage)Copy Code
Dim instance As ObjectContext
Dim typeSelector As PersistentTypeSelector
Dim conditions As String
Dim parameter() As Object
Dim value As ObjectSet(Of T)
 
value = instance.GetObjectSet(Of T)(typeSelector, conditions, parameter)
C# 
public virtual ObjectSet<T> GetObjectSet<T>( 
   PersistentTypeSelector typeSelector,
   string conditions,
   params object[] parameter
)
Managed Extensions for C++ 
public: virtual ObjectSet<T>* GetObjectSet<T>( 
   PersistentTypeSelector* typeSelector,
   string* conditions,
   params Object*[]* parameter
) 
C++/CLI 
public:
virtual ObjectSet<T>^ GetObjectSetgeneric<typename T>
( 
   PersistentTypeSelector^ typeSelector,
   String^ conditions,
   ... array<Object^>^ parameter
) 

Parameters

typeSelector
Delegate invoked before each creating of a persistent object. This allows to dynamically change the type of the created persistent object or ignore some objects.
conditions
A condition string that specifies the objects that are loaded.
parameter
A list of parameter that is passed as parameter for the conditions.

Type Parameters

T

Return Value

An instance of an ObjectSet filled with the objects from the storage.

Example

The following example introduces to the use of the GetObjectSet routine.
C#Copy Code
// Creates a new ObjectContext that uses an MsSql Server as storage. 
ObjectContext context = new ObjectContext(new MsSqlStorage("sa", "",  
    "localhost", "application")); 
  
// ... Other code. 
  
// Get the ObjectSet with user matching the name and sorting them by name. 
ObjectSet<User> objectSet = context.GetObjectSet<User> 
    (new PersistentTypeSelector(MySelection), "Name like {0} SortBy Name Asc", "%mith%"); 
  
// Loop through all items and do something. 
foreach(User user in objectSet) 

    // Do something. 

 
// ... 
 
private void MySelection(object sender, FetchingStorageRecordEventArgs e) 

    if (e.DataRecord["Type"] == "1") 
    { 
        // Switch the type of the persistent that is created to User1. 
        e.Type = typeof(User1); 
    } 
    // Have a persistent of type User created. 
    e.Type = typeof(User); 

    

Remarks

Returns a filled ObjectSet. An ObjectSet is as a in memory cache for objects. Use the conditions to restrict the result of the routine.

Requirements

Platforms: Windows 2000, Windows XP family, Windows Server 2003 family, Windows Vista family

See Also